﻿@model XStudio.Framework.Common.Entity.Parameter.HashParameterEntity
@using XStudio.Core.Ext
<script type="text/javascript">
    $(function () {

        // jQuery.validator增加IP验证
        jQuery.validator.addMethod("code", function (value, element) {
            return this.optional(element) || (/^[a-zA-Z0-9_]+$/.test(value));
        }, "请输入英文、数字");

        var v = $('#frmParamInput').validate({
            rules: {
                HashKey: { required: true, code: true },
                HashValue: { required: true }
            },
            messages: {
                HashKey: { required: "必填项！" },
                HashValue: { required: "必填项！" }
            }
        });
    });

    var ParamInput = {};
    ParamInput.Save = function (e) {
        var frm = $(e).parents("form").first();
        if (!$(frm).valid())
            return;

        $.post($(frm).attr("action"), $(frm).serialize(), function (data) {
            if (data.IsOK) {
                var selectedTab = $('#tabsMain').tabs('getSelected');
                $(selectedTab).find("table[idfield='UID']").datagrid("reload");

                //关闭选项卡
                $.closeWin(e);
            }
            else
                alert(data.Description);
        });
    }

</script>
<form name="frmParamInput" id="frmParamInput" method=post action="@Url.Action(ViewContext.RouteData.Values["Action"].ToString(), new { ParameterID = ViewBag.ParameterID })" >
<table class="tbl-input" cellspacing="0" style="margin: 5px auto;">
    <tbody>
        <tr>
            <th>
                配置键值：
            </th>
            <td>
                @Html.TextBoxFor(t => t.HashKey, new { style = "width:200px", maxlength = "100" })
            </td>
            <td class="slight">
                <span class="btn-infomust">必填项</span>
            </td>
        </tr>
        <tr>
            <th>
                配置值：
            </th>
            <td>
                @Html.TextAreaFor(t => t.HashValue, new { style = "width:200px", rows = 4 })
            </td>
            <td class="slight">
                <span class="btn-infomust">必填项</span>
            </td>
        </tr>
        <tr>
            <th>
                备注：
            </th>
            <td>
                @Html.TextAreaFor(t => t.Remark, new { style = "width:200px", rows = 4 })
            </td>
            <td class="slight">
                <span class="btn-info">选填项</span>
            </td>
        </tr>
        <tr>
            <th>
            </th>
            <td>
                <input type="checkbox" id="chkStateCodeID" @(Model.StateCode == "Enable" ? "checked='checked'" : "")  name="StateCodeID" value="1" />
                <label for="chkStateCodeID">
                    是否启用
                </label>
            </td>
            <td class="slight">
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center;">
                <p class="op">
                    <input type="button" id="btnSave" onclick="ParamInput.Save(this);" class="btn-8"
                        value="保存" />
                    <input type="button" value="返回" onclick="$.closeWin(this);" class="btn-8" />
                </p>
            </td>
        </tr>
    </tbody>
</table>
</form>
